'use strict';

const Sequelize = require('sequelize');
const sequelize = require('../util/sequelize');

var User = sequelize.define('user', {
    number: {
        type: Sequelize.INTEGER,
    },
    openId: {
        type: Sequelize.STRING
    },
    nickName: {
        type: Sequelize.STRING,
        allowNull: true,
    },
    language: {
        type: Sequelize.STRING,
        allowNull: true,
    },
    gender: {
        type: Sequelize.INTEGER,
        allowNull: true,
    },
    city: {
        type: Sequelize.STRING,
        allowNull: true,
    },
    province: {
        type: Sequelize.STRING,
        allowNull: true,
    },
    avatarUrl: {
        type: Sequelize.STRING,
        allowNull: true,
    },
    address: {
        type: Sequelize.STRING,
        allowNull: true,
    },
    latitude: {
        type: Sequelize.DOUBLE,
        allowNull: true,
        defaultValue: null,
        validate: {
            min: -90,
            max: 90
        }
    },
    longitude: {
        type: Sequelize.DOUBLE,
        allowNull: true,
        defaultValue: null,
        validate: {
            min: -180,
            max: 180
        }
    },
    level: {
        type: Sequelize.STRING,
        allowNull: true,
        defaultValue: null
    },
    credit: {
        type: Sequelize.INTEGER,
        defaultValue: 0
    },
    balance: {
        type: Sequelize.DOUBLE,
        defaultValue: 0.00
    }
});

User.sync({
    force: false
});
module.exports = User;